package TestDemo8;

import java.util.Scanner;

public class Test {
    public static void convert(int m,int n){

        if(m < n){
            switch (m) {
                case 10:
                    System.out.print('A');
                    return;
                case 11:
                    System.out.print('B');
                    return;
                case 12:
                    System.out.print('C');
                    return;
                case 13:
                    System.out.print('D');
                    return;
                case 14:
                    System.out.print('E');
                    return;
                case 15:
                    System.out.print('F');
                    return;
                default:
                    System.out.print(m);
                    return;
            }
        }
        int temp=m/n;
        convert(temp,n);
        switch (m%n) {
            case 10:
                System.out.print('A');
                return;
            case 11:
                System.out.print('B');
                return;
            case 12:
                System.out.print('C');
                return;
            case 13:
                System.out.print('D');
                return;
            case 14:
                System.out.print('E');
                return;
            case 15:
                System.out.print('F');
                return;
            default:
                System.out.print(m%n);

        }

    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        //数值
        int m=sc.nextInt();
        //进制
        int n=sc.nextInt();
        if(m<0){
            System.out.print('-');
            m=-m;
        }
        convert(m,n);
    }
}
